package com.complex.ognl;

import java.math.BigDecimal;

import ognl.Ognl;
import ognl.OgnlException;

import com.complex.drools.Transport;

public class OgnlDemo {
	public static void main(String[] args) {
		Transport transport = new Transport();
		transport.setCharge(new BigDecimal(600));// 设置保价
		transport.setRate(new BigDecimal(0.003));// 设置费率
		transport.setMode("1");// 设置运输方式

		try {
			// 保价*费率
			String exp = "#this.charge.multiply(#this.rate)";

			// 根据配置的表达式计算
			BigDecimal value = (BigDecimal) Ognl.getValue(exp, transport);

			System.out.println(value);
		} catch (OgnlException e) {
			e.printStackTrace();
		}
	}
}
